package com.example.tool;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetManager {
	
	private static NetManager netManager;
	
	private NetManager(){
	}
	
	public static NetManager getInstance(final Context context){
		if(netManager==null){
			netManager=new NetManager();
		}
		return netManager;
	}
	
	public boolean isNetWorkStatus(Context context){
        ConnectivityManager cwjManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netWrokInfo = cwjManager.getActiveNetworkInfo() ;
        
        if (netWrokInfo != null && netWrokInfo.isAvailable()) {
            return true;
        }
        return false;
	}
	
	public boolean isMobileNetwork(Context context){
		ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo netWrokInfo = manager.getActiveNetworkInfo();
		if (netWrokInfo!=null &&netWrokInfo.getType()== ConnectivityManager.TYPE_MOBILE) {
			return true;
		}
		return false;
	}
	
}
